<?php

require_once "data/dao/GameDAO.php";
require_once "data/dao/CollectionDAO.php";
require_once "data/dao/WishListDAO.php";
require_once "application/game/Locale.php";

class Game{
	
	private $id;
	private $title;
	private $manufacturer;
	private $releaseDate;
	private $imageURL;
	private $largeImageURL;
	private $amazonAssociateURL;
	private $locale;
	private $description;
	
	public function Game($id, $title, $manufacturer, $releaseDate, $imageURL, $largeImageURL, 
		$amazonAssociateURL, $locale, $description){
			
			$this->id = $id;
			$this->title = $title;
			$this->manufacturer = $manufacturer;
			$this->releaseDate = $releaseDate;
			$this->imageURL = $imageURL;
			$this->largeImageURL = $largeImageURL;
			$this->amazonAssociateURL = $amazonAssociateURL;
			$this->locale = $locale;
			$this->description = $description;
	}
	
	public function getID(){
		return $this->id;
	}
	
	public function getTitle(){
		return $this->title;
	}
	
	public function getManufacturer(){
		return $this->manufacturer;
	}
	
	public function getReleaseDate(){
		return $this->releaseDate;
	}
	
	public function getImageURL(){

		return $this->imageURL;
	}
	
	public function getLargeImageURL(){
		return $this->largeImageURL;
	}
	
	public function getAmazonAssociateURL(){
		return urlencode($this->amazonAssociateURL);
	}
	
	public function getLocale(){
		return $this->locale;
	}
	
	public function getDescription(){
		return $this->description;
	}
	
	const UK_FLAG_SRC = "http://wii-social.com/html/images/gb.png";
	const US_FLAG_SRC = "http://wii-social.com/html/images/us.png";
	const WII_WARE_FLAG_SRC = "http://wii-social.com/html/images/wiiware.png";
	
	
	public function getLocaleFlagSrc($locale){
		
		$localeFlagMap = array(Locale::UK_LOCALE => self::UK_FLAG_SRC,
							   Locale::US_LOCALE => self::US_FLAG_SRC,
							   "wii-ware" => self::WII_WARE_FLAG_SRC);
							   
		return $localeFlagMap[$locale];
	}
	
	const UK_FLAG_TITLE = "Amazon.co.uk";
	const US_FLAG_TITLE = "Amazon.com";
	const WII_WARE_FLAG_TITLE = "WiiWare";
	
	public function getLocaleFlagTitle($locale){
		
		$localeTitleMap = array(Locale::UK_LOCALE => self::UK_FLAG_TITLE,
							   Locale::US_LOCALE => self::US_FLAG_TITLE,
							   "wii-ware" => self::WII_WARE_FLAG_TITLE);
							   
		return $localeTitleMap[$locale];
	}
	
	public function getNumberOfPlayers(){
		
		$cdao = new CollectionDAO();
		return $cdao->getNumberOfCollectionsContainingGame($this->id);
	}

	public function getNumberOfWishLists(){
		
		$wldao = new WishListDAO();
		return $wldao->getNumberOfWishListsContainingGame($this->id);
	}
}
?>
